package kusterordonio.interfaz;

import java.awt.event.KeyEvent;
import java.util.*;
import java.text.*;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import kusterordonio.dominio.*;

public class VentanaSaludOcular extends javax.swing.JFrame {
    
    private SistemaCarne modelo;
    private Ninio niño;
    private FuncionesAuxiliares funcAux;
    private DefaultTableModel tabla;
    private Persona actor;
    private boolean caso;
    
    /** Creates new form VentanaSaludOcular */
    public VentanaSaludOcular() {
        initComponents();
    }
    
    public VentanaSaludOcular(SistemaCarne unSistema, Ninio unNiño, FuncionesAuxiliares unaFunc, Persona unActor, boolean unCaso) {
        modelo = unSistema;
        niño = unNiño;
        funcAux = unaFunc;
        tabla = new DefaultTableModel();
        actor= unActor;
        caso = unCaso;
        initComponents();
        controlGenero();
        controlCaso();
        cargarDatos();
        cargarEncabezados();
        cargarTabla();
        jBtnSalir.setMnemonic(KeyEvent.VK_S);
        jBtnConfirmar.setMnemonic(KeyEvent.VK_C);
        jDateFecha.setMaxSelectableDate(Calendar.getInstance().getTime());
        jDateFecha.setMinSelectableDate(niño.getFechaNac());
    }
    
    //Carga los encabezados de la tabla
    public void cargarEncabezados(){
        tabla.addColumn("Fecha");
        tabla.addColumn("Diagnóstico y tratamiento");
        tabla.addColumn("Médico");
    }
    
    //setea los elementos de la ventana según el rol del actor
    public void controlCaso(){
        jTxtDiagnostico.setEditable(caso);
        jTxtDiagnostico.setVisible(caso);
        jDateFecha.setEnabled(caso);
        jDateFecha.setVisible(caso);
        jTextFecha.setVisible(caso);
        jTextDiag.setVisible(caso);
        jCheck3ODCC.setEnabled(caso);
        jCheck3ODSC.setEnabled(caso);
        jCheck3OICC.setEnabled(caso);
        jCheck3OISC.setEnabled(caso);
        jCheck5ODCC.setEnabled(caso);
        jCheck5ODSC.setEnabled(caso);
        jCheck5OICC.setEnabled(caso);
        jCheck5OISC.setEnabled(caso);
        jCheck12ODCC.setEnabled(caso);
        jCheck12ODSC.setEnabled(caso);
        jCheck12OICC.setEnabled(caso);
        jCheck12OISC.setEnabled(caso);
        jBtnConfirmar.setVisible(caso);
        if(!caso)
            jScrollPane2.setBounds(30,280,590,160);
    }
    
    //Controla los elementos de la ventana según el sexo del niño
    public void controlGenero(){
        if(!niño.isSexo()){
            jLabelTitulo.setForeground(new java.awt.Color(255, 153, 0));
            jLabelTitular.setForeground(new java.awt.Color(255, 153, 0));
            jLabelPrematuro1.setVisible(false);
            jLabelPrematuro2.setVisible(false);
            jTextDiag.setBackground(new java.awt.Color(255, 153, 0));
            jTextEdad.setBackground(new java.awt.Color(255, 153, 0));
            jTextFecha.setBackground(new java.awt.Color(255, 153, 0));
            jTextOd.setBackground(new java.awt.Color(255, 153, 0));
            jTextOi.setBackground(new java.awt.Color(255, 153, 0));
            jText3.setBackground(new java.awt.Color(255, 153, 0));
            jText5.setBackground(new java.awt.Color(255, 153, 0));
            jText12.setBackground(new java.awt.Color(255, 153, 0));
            jText3cc.setBackground(new java.awt.Color(255, 204, 153));
            jText3sc.setBackground(new java.awt.Color(255, 204, 153));
            jText5cc.setBackground(new java.awt.Color(255, 204, 153));
            jText5sc.setBackground(new java.awt.Color(255, 204, 153));
            jText12cc.setBackground(new java.awt.Color(255, 204, 153));
            jText12sc.setBackground(new java.awt.Color(255, 204, 153));
        }else{
            jLabelPrematura1.setVisible(false);
            jLabelPrematura2.setVisible(false);
        }
    }
    
    public void cargarDatos(){
        jLabelNombre.setText(niño.toString());
        if(niño.getCarne().getSaludOcular().getControles()[0]){
           this.jCheck3ODCC.setSelected(true);
           this.jCheck3ODSC.setEnabled(false);
           this.jCheck3ODCC.setEnabled(false);
        }
        if(niño.getCarne().getSaludOcular().getControles()[1]){
           this.jCheck3ODSC.setSelected(true);
           this.jCheck3ODSC.setEnabled(false);
           this.jCheck3ODCC.setEnabled(false);
        }
        if(niño.getCarne().getSaludOcular().getControles()[2]){
           this.jCheck5ODCC.setSelected(true);
           this.jCheck5ODSC.setEnabled(false);
           this.jCheck5ODCC.setEnabled(false);
        }
        if(niño.getCarne().getSaludOcular().getControles()[3]){
           this.jCheck5ODSC.setSelected(true);
           this.jCheck5ODSC.setEnabled(false);
           this.jCheck5ODCC.setEnabled(false);
        }
        if(niño.getCarne().getSaludOcular().getControles()[4]){
           this.jCheck12ODCC.setSelected(true);
           this.jCheck12ODSC.setEnabled(false);
           this.jCheck12ODCC.setEnabled(false);
        }
        if(niño.getCarne().getSaludOcular().getControles()[5]){
           this.jCheck12ODSC.setSelected(true);
           this.jCheck12ODSC.setEnabled(false);
           this.jCheck12ODCC.setEnabled(false);
        }
        if(niño.getCarne().getSaludOcular().getControles()[6]){
           this.jCheck3OICC.setSelected(true);
           this.jCheck3OISC.setEnabled(false);
           this.jCheck3OICC.setEnabled(false);
        }
        if(niño.getCarne().getSaludOcular().getControles()[7]){
           this.jCheck3OISC.setSelected(true);
           this.jCheck3OISC.setEnabled(false);
           this.jCheck3OICC.setEnabled(false);
        }
        if(niño.getCarne().getSaludOcular().getControles()[8]){
           this.jCheck5OICC.setSelected(true);
           this.jCheck5OISC.setEnabled(false);
           this.jCheck5OICC.setEnabled(false);
        }
        if(niño.getCarne().getSaludOcular().getControles()[9]){
           this.jCheck5OISC.setSelected(true);
           this.jCheck5OISC.setEnabled(false);
           this.jCheck5OICC.setEnabled(false);
        }
        if(niño.getCarne().getSaludOcular().getControles()[10]){
           this.jCheck12OICC.setSelected(true);
           this.jCheck12OISC.setEnabled(false);
           this.jCheck12OICC.setEnabled(false);
        }
        if(niño.getCarne().getSaludOcular().getControles()[11]){
           this.jCheck12OISC.setSelected(true);
           this.jCheck12OISC.setEnabled(false);
           this.jCheck12OICC.setEnabled(false);
        }
    }
    
    public void cargarTabla(){
        if(!niño.getCarne().getSaludOcular().esVaciaDiagnosticos()){
            //Despejamos la tabla para volver a cargarla
            int row = tabla.getRowCount();
            if(tabla.getRowCount() != 0){
                 while(row> 0){
                     tabla.removeRow(0);
                     row--;
                 }
            }
            //Cargamos la tabla
            ArrayList<SaludOcularDiagnostico> lista= niño.getCarne().getSaludOcular().getDiagnosticos();
            SimpleDateFormat formato = new SimpleDateFormat("dd/MM/yyyy");
            for(int i=0; i<lista.size(); i++){
                Object[] linea = new Object[3]; 
                linea[0] = formato.format(lista.get(i).getFecha()); 
                linea[1] = lista.get(i).getDiagTratamiento(); 
                linea[2] = lista.get(i).getMedico(); 
                tabla.addRow(linea);
            }
        }
        jTable1.setModel(tabla);
        jTable1.getColumnModel().getColumn(0).setMaxWidth(95);
        jTable1.getColumnModel().getColumn(1).setMaxWidth(375);
        jTable1.getColumnModel().getColumn(0).setMinWidth(95);
        jTable1.getColumnModel().getColumn(1).setMinWidth(375);
    }
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        buttonGroup3 = new javax.swing.ButtonGroup();
        buttonGroup4 = new javax.swing.ButtonGroup();
        buttonGroup5 = new javax.swing.ButtonGroup();
        buttonGroup6 = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        jLabelTitulo = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jTextEdad = new javax.swing.JTextField();
        jTextOd = new javax.swing.JTextField();
        jTextOi = new javax.swing.JTextField();
        jText3 = new javax.swing.JTextField();
        jText5 = new javax.swing.JTextField();
        jText12 = new javax.swing.JTextField();
        jText3cc = new javax.swing.JTextField();
        jText3sc = new javax.swing.JTextField();
        jText5cc = new javax.swing.JTextField();
        jText5sc = new javax.swing.JTextField();
        jText12cc = new javax.swing.JTextField();
        jText12sc = new javax.swing.JTextField();
        jCheck3ODCC = new javax.swing.JCheckBox();
        jCheck3ODSC = new javax.swing.JCheckBox();
        jCheck3OICC = new javax.swing.JCheckBox();
        jCheck3OISC = new javax.swing.JCheckBox();
        jCheck5ODCC = new javax.swing.JCheckBox();
        jCheck5ODSC = new javax.swing.JCheckBox();
        jCheck5OICC = new javax.swing.JCheckBox();
        jCheck5OISC = new javax.swing.JCheckBox();
        jCheck12ODCC = new javax.swing.JCheckBox();
        jCheck12ODSC = new javax.swing.JCheckBox();
        jCheck12OICC = new javax.swing.JCheckBox();
        jCheck12OISC = new javax.swing.JCheckBox();
        jTextField13 = new javax.swing.JTextField();
        jTextField14 = new javax.swing.JTextField();
        jTextField15 = new javax.swing.JTextField();
        jTextField16 = new javax.swing.JTextField();
        jTextField17 = new javax.swing.JTextField();
        jTextField18 = new javax.swing.JTextField();
        jTextField19 = new javax.swing.JTextField();
        jTextField20 = new javax.swing.JTextField();
        jTextField21 = new javax.swing.JTextField();
        jTextField22 = new javax.swing.JTextField();
        jTextField23 = new javax.swing.JTextField();
        jTextField24 = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabelPrematuro1 = new javax.swing.JLabel();
        jLabelPrematuro2 = new javax.swing.JLabel();
        jLabelPrematura1 = new javax.swing.JLabel();
        jLabelPrematura2 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jBtnConfirmar = new javax.swing.JButton();
        jBtnSalir = new javax.swing.JButton();
        jDateFecha = new com.toedter.calendar.JDateChooser();
        jTxtDiagnostico = new javax.swing.JTextField();
        jTextFecha = new javax.swing.JTextField();
        jTextDiag = new javax.swing.JTextField();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jLabelTitular = new javax.swing.JLabel();
        jLabelNombre = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Salud Ocular");
        setBounds(new java.awt.Rectangle(200, 100, 0, 0));
        setResizable(false);

        jPanel1.setPreferredSize(new java.awt.Dimension(100, 100));
        jPanel1.setLayout(null);

        jLabelTitulo.setFont(new java.awt.Font("Tahoma", 1, 18));
        jLabelTitulo.setForeground(new java.awt.Color(51, 153, 0));
        jLabelTitulo.setText("Salud ocular");
        jPanel1.add(jLabelTitulo);
        jLabelTitulo.setBounds(20, 20, 140, 20);
        jPanel1.add(jSeparator1);
        jSeparator1.setBounds(0, 50, 700, 10);

        jTextEdad.setBackground(new java.awt.Color(51, 153, 0));
        jTextEdad.setEditable(false);
        jTextEdad.setFont(new java.awt.Font("Tahoma", 1, 11));
        jTextEdad.setForeground(new java.awt.Color(255, 255, 255));
        jTextEdad.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jTextEdad.setText("Edad / años");
        jPanel1.add(jTextEdad);
        jTextEdad.setBounds(30, 70, 85, 20);

        jTextOd.setBackground(new java.awt.Color(51, 153, 0));
        jTextOd.setEditable(false);
        jTextOd.setFont(new java.awt.Font("Tahoma", 1, 11));
        jTextOd.setForeground(new java.awt.Color(255, 255, 255));
        jTextOd.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jTextOd.setText("OD");
        jPanel1.add(jTextOd);
        jTextOd.setBounds(115, 70, 85, 20);

        jTextOi.setBackground(new java.awt.Color(51, 153, 0));
        jTextOi.setEditable(false);
        jTextOi.setFont(new java.awt.Font("Tahoma", 1, 11));
        jTextOi.setForeground(new java.awt.Color(255, 255, 255));
        jTextOi.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jTextOi.setText("OI");
        jPanel1.add(jTextOi);
        jTextOi.setBounds(200, 70, 85, 20);

        jText3.setBackground(new java.awt.Color(51, 153, 0));
        jText3.setEditable(false);
        jText3.setFont(new java.awt.Font("Tahoma", 1, 11));
        jText3.setForeground(new java.awt.Color(255, 255, 255));
        jText3.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jText3.setText("3 años");
        jPanel1.add(jText3);
        jText3.setBounds(30, 90, 50, 40);

        jText5.setBackground(new java.awt.Color(51, 153, 0));
        jText5.setEditable(false);
        jText5.setFont(new java.awt.Font("Tahoma", 1, 11));
        jText5.setForeground(new java.awt.Color(255, 255, 255));
        jText5.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jText5.setText("5 años");
        jPanel1.add(jText5);
        jText5.setBounds(30, 130, 50, 40);

        jText12.setBackground(new java.awt.Color(51, 153, 0));
        jText12.setEditable(false);
        jText12.setFont(new java.awt.Font("Tahoma", 1, 11));
        jText12.setForeground(new java.awt.Color(255, 255, 255));
        jText12.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jText12.setText("12 años");
        jPanel1.add(jText12);
        jText12.setBounds(30, 170, 50, 40);

        jText3cc.setBackground(new java.awt.Color(204, 204, 0));
        jText3cc.setEditable(false);
        jText3cc.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jText3cc.setText("CC");
        jPanel1.add(jText3cc);
        jText3cc.setBounds(80, 90, 35, 20);

        jText3sc.setBackground(new java.awt.Color(204, 204, 0));
        jText3sc.setEditable(false);
        jText3sc.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jText3sc.setText("SC");
        jPanel1.add(jText3sc);
        jText3sc.setBounds(80, 110, 35, 20);

        jText5cc.setBackground(new java.awt.Color(204, 204, 0));
        jText5cc.setEditable(false);
        jText5cc.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jText5cc.setText("CC");
        jPanel1.add(jText5cc);
        jText5cc.setBounds(80, 130, 35, 20);

        jText5sc.setBackground(new java.awt.Color(204, 204, 0));
        jText5sc.setEditable(false);
        jText5sc.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jText5sc.setText("SC");
        jPanel1.add(jText5sc);
        jText5sc.setBounds(80, 150, 35, 20);

        jText12cc.setBackground(new java.awt.Color(204, 204, 0));
        jText12cc.setEditable(false);
        jText12cc.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jText12cc.setText("CC");
        jPanel1.add(jText12cc);
        jText12cc.setBounds(80, 170, 35, 20);

        jText12sc.setBackground(new java.awt.Color(204, 204, 0));
        jText12sc.setEditable(false);
        jText12sc.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jText12sc.setText("SC");
        jPanel1.add(jText12sc);
        jText12sc.setBounds(80, 190, 35, 20);

        buttonGroup1.add(jCheck3ODCC);
        jCheck3ODCC.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jPanel1.add(jCheck3ODCC);
        jCheck3ODCC.setBounds(150, 92, 15, 15);

        buttonGroup1.add(jCheck3ODSC);
        jCheck3ODSC.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jPanel1.add(jCheck3ODSC);
        jCheck3ODSC.setBounds(150, 112, 15, 15);

        buttonGroup2.add(jCheck3OICC);
        jCheck3OICC.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jPanel1.add(jCheck3OICC);
        jCheck3OICC.setBounds(235, 92, 15, 15);

        buttonGroup2.add(jCheck3OISC);
        jCheck3OISC.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jPanel1.add(jCheck3OISC);
        jCheck3OISC.setBounds(235, 112, 15, 15);

        buttonGroup3.add(jCheck5ODCC);
        jCheck5ODCC.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jPanel1.add(jCheck5ODCC);
        jCheck5ODCC.setBounds(150, 132, 15, 15);

        buttonGroup3.add(jCheck5ODSC);
        jCheck5ODSC.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jPanel1.add(jCheck5ODSC);
        jCheck5ODSC.setBounds(150, 152, 15, 15);

        buttonGroup4.add(jCheck5OICC);
        jCheck5OICC.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jPanel1.add(jCheck5OICC);
        jCheck5OICC.setBounds(235, 132, 15, 15);

        buttonGroup4.add(jCheck5OISC);
        jCheck5OISC.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jPanel1.add(jCheck5OISC);
        jCheck5OISC.setBounds(235, 152, 15, 15);

        buttonGroup5.add(jCheck12ODCC);
        jCheck12ODCC.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jPanel1.add(jCheck12ODCC);
        jCheck12ODCC.setBounds(150, 172, 15, 15);

        buttonGroup5.add(jCheck12ODSC);
        jCheck12ODSC.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jPanel1.add(jCheck12ODSC);
        jCheck12ODSC.setBounds(150, 192, 15, 15);

        buttonGroup6.add(jCheck12OICC);
        jCheck12OICC.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jPanel1.add(jCheck12OICC);
        jCheck12OICC.setBounds(235, 172, 15, 15);

        buttonGroup6.add(jCheck12OISC);
        jCheck12OISC.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jPanel1.add(jCheck12OISC);
        jCheck12OISC.setBounds(235, 192, 15, 15);

        jTextField13.setEditable(false);
        jTextField13.setOpaque(false);
        jPanel1.add(jTextField13);
        jTextField13.setBounds(115, 90, 85, 20);

        jTextField14.setEditable(false);
        jTextField14.setOpaque(false);
        jPanel1.add(jTextField14);
        jTextField14.setBounds(200, 90, 85, 20);

        jTextField15.setEditable(false);
        jTextField15.setOpaque(false);
        jPanel1.add(jTextField15);
        jTextField15.setBounds(115, 110, 85, 20);

        jTextField16.setEditable(false);
        jTextField16.setOpaque(false);
        jPanel1.add(jTextField16);
        jTextField16.setBounds(200, 110, 85, 20);

        jTextField17.setEditable(false);
        jTextField17.setOpaque(false);
        jPanel1.add(jTextField17);
        jTextField17.setBounds(115, 130, 85, 20);

        jTextField18.setEditable(false);
        jTextField18.setOpaque(false);
        jPanel1.add(jTextField18);
        jTextField18.setBounds(200, 130, 85, 20);

        jTextField19.setEditable(false);
        jTextField19.setOpaque(false);
        jPanel1.add(jTextField19);
        jTextField19.setBounds(115, 150, 85, 20);

        jTextField20.setEditable(false);
        jTextField20.setOpaque(false);
        jPanel1.add(jTextField20);
        jTextField20.setBounds(200, 150, 85, 20);

        jTextField21.setEditable(false);
        jTextField21.setOpaque(false);
        jPanel1.add(jTextField21);
        jTextField21.setBounds(115, 170, 85, 20);

        jTextField22.setEditable(false);
        jTextField22.setOpaque(false);
        jPanel1.add(jTextField22);
        jTextField22.setBounds(200, 170, 85, 20);

        jTextField23.setEditable(false);
        jTextField23.setOpaque(false);
        jPanel1.add(jTextField23);
        jTextField23.setBounds(115, 190, 85, 20);

        jTextField24.setEditable(false);
        jTextField24.setOpaque(false);
        jPanel1.add(jTextField24);
        jTextField24.setBounds(200, 190, 85, 20);

        jTextArea1.setColumns(20);
        jTextArea1.setEditable(false);
        jTextArea1.setFont(new java.awt.Font("Tahoma", 0, 11));
        jTextArea1.setRows(5);
        jTextArea1.setText("- Megalocornea\n- Pupila blanca\n- Ptosis palpebral\n- Desviación ocular permanente\n- Vagabundeo ocular\n- Lagrimeo en los primeros días de vida");
        jScrollPane1.setViewportView(jTextArea1);

        jPanel1.add(jScrollPane1);
        jScrollPane1.setBounds(340, 110, 240, 100);

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel2.setText("Signos que requieren consulta con el Oftalmólogo");
        jPanel1.add(jLabel2);
        jLabel2.setBounds(340, 70, 320, 30);

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 9)); // NOI18N
        jLabel3.setText("* OD-ojo derecho / OI-ojo izquierdo / CC-con corrección / SC-sin correción");
        jPanel1.add(jLabel3);
        jLabel3.setBounds(30, 210, 350, 10);

        jLabelPrematuro1.setFont(new java.awt.Font("Tahoma", 0, 9));
        jLabelPrematuro1.setText("* Prematuro menor de 28 semanas de edad gestacional o peso menor a 1500 g debe iniciar control de retina a las 31 semanas de edad corregida.");
        jPanel1.add(jLabelPrematuro1);
        jLabelPrematuro1.setBounds(30, 230, 600, 20);

        jLabelPrematuro2.setFont(new java.awt.Font("Tahoma", 0, 9));
        jLabelPrematuro2.setText("* Prematuro nacido entre 28 y 32 semanas de edad gestacional debe iniciar control de retina a partir del primer mes de vida");
        jPanel1.add(jLabelPrematuro2);
        jLabelPrematuro2.setBounds(30, 250, 600, 20);

        jLabelPrematura1.setFont(new java.awt.Font("Tahoma", 0, 9));
        jLabelPrematura1.setText("* Prematura menor de 28 semanas de edad gestacional o peso menor a 1500 g debe iniciar control de retina a las 31 semanas de edad corregida.");
        jPanel1.add(jLabelPrematura1);
        jLabelPrematura1.setBounds(30, 230, 600, 20);

        jLabelPrematura2.setFont(new java.awt.Font("Tahoma", 0, 9));
        jLabelPrematura2.setText("* Prematura nacida entre 28 y 32 semanas de edad gestacional debe iniciar control de retina a partir del primer mes de vida");
        jPanel1.add(jLabelPrematura2);
        jLabelPrematura2.setBounds(30, 250, 600, 20);

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 9));
        jLabel4.setText("Programa Nacional de Salud Ocular - MSP.");
        jPanel1.add(jLabel4);
        jLabel4.setBounds(30, 440, 600, 20);

        jBtnConfirmar.setText("Confirmar Cambios");
        jBtnConfirmar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnConfirmarActionPerformed(evt);
            }
        });
        jPanel1.add(jBtnConfirmar);
        jBtnConfirmar.setBounds(150, 470, 130, 23);

        jBtnSalir.setText("Salir");
        jBtnSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnSalirActionPerformed(evt);
            }
        });
        jPanel1.add(jBtnSalir);
        jBtnSalir.setBounds(370, 470, 130, 22);

        jDateFecha.setDateFormatString("dd/MM/yyyy");
        jPanel1.add(jDateFecha);
        jDateFecha.setBounds(30, 302, 90, 22);
        jPanel1.add(jTxtDiagnostico);
        jTxtDiagnostico.setBounds(120, 302, 500, 22);

        jTextFecha.setBackground(new java.awt.Color(51, 153, 0));
        jTextFecha.setEditable(false);
        jTextFecha.setFont(new java.awt.Font("Tahoma", 1, 11));
        jTextFecha.setForeground(new java.awt.Color(255, 255, 255));
        jTextFecha.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jTextFecha.setText("Fecha");
        jPanel1.add(jTextFecha);
        jTextFecha.setBounds(30, 280, 90, 22);

        jTextDiag.setBackground(new java.awt.Color(51, 153, 0));
        jTextDiag.setEditable(false);
        jTextDiag.setFont(new java.awt.Font("Tahoma", 1, 11));
        jTextDiag.setForeground(new java.awt.Color(255, 255, 255));
        jTextDiag.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jTextDiag.setText("Diagnóstico y tratamiento");
        jPanel1.add(jTextDiag);
        jTextDiag.setBounds(120, 280, 500, 22);

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_LAST_COLUMN);
        jTable1.setRowHeight(20);
        jTable1.setRowSelectionAllowed(false);
        jScrollPane2.setViewportView(jTable1);
        jTable1.getColumnModel().getColumn(0).setResizable(false);
        jTable1.getColumnModel().getColumn(1).setResizable(false);
        jTable1.getColumnModel().getColumn(2).setResizable(false);
        jTable1.getColumnModel().getColumn(3).setResizable(false);

        jPanel1.add(jScrollPane2);
        jScrollPane2.setBounds(30, 330, 590, 110);

        jLabelTitular.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabelTitular.setForeground(new java.awt.Color(51, 153, 0));
        jLabelTitular.setText("Titular:");
        jPanel1.add(jLabelTitular);
        jLabelTitular.setBounds(340, 25, 50, 20);

        jLabelNombre.setFont(new java.awt.Font("Tahoma", 1, 14));
        jPanel1.add(jLabelNombre);
        jLabelNombre.setBounds(400, 25, 220, 20);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 650, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 515, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
private void jBtnSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnSalirActionPerformed
    this.dispose();
}//GEN-LAST:event_jBtnSalirActionPerformed

private void jBtnConfirmarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnConfirmarActionPerformed
    if(funcAux.verificarCheckBox(jCheck3ODCC)) niño.getCarne().getSaludOcular().getControles()[0] = true;
    if(funcAux.verificarCheckBox(jCheck3ODSC)) niño.getCarne().getSaludOcular().getControles()[1] = true;
    if(funcAux.verificarCheckBox(jCheck5ODCC)) niño.getCarne().getSaludOcular().getControles()[2] = true;
    if(funcAux.verificarCheckBox(jCheck5ODSC)) niño.getCarne().getSaludOcular().getControles()[3] = true;
    if(funcAux.verificarCheckBox(jCheck12ODCC)) niño.getCarne().getSaludOcular().getControles()[4] = true;
    if(funcAux.verificarCheckBox(jCheck12ODSC)) niño.getCarne().getSaludOcular().getControles()[5] = true;
    if(funcAux.verificarCheckBox(jCheck3OICC)) niño.getCarne().getSaludOcular().getControles()[6] = true;
    if(funcAux.verificarCheckBox(jCheck3OISC)) niño.getCarne().getSaludOcular().getControles()[7] = true;
    if(funcAux.verificarCheckBox(jCheck5OICC)) niño.getCarne().getSaludOcular().getControles()[8] = true;
    if(funcAux.verificarCheckBox(jCheck5OISC)) niño.getCarne().getSaludOcular().getControles()[9] = true;
    if(funcAux.verificarCheckBox(jCheck12OICC)) niño.getCarne().getSaludOcular().getControles()[10] = true;
    if(funcAux.verificarCheckBox(jCheck12OISC)) niño.getCarne().getSaludOcular().getControles()[11] = true;
    if(jDateFecha.getDate() != null && niño.controlFecha(jDateFecha.getDate()) && !jTxtDiagnostico.getText().equals("")){
        SaludOcularDiagnostico nuevo = new SaludOcularDiagnostico(jDateFecha.getDate(), jTxtDiagnostico.getText(), actor);
        niño.getCarne().getSaludOcular().agregarDiagnostico(nuevo);
        jTxtDiagnostico.setText("");
        jDateFecha.setDate(null);
        cargarTabla();
    }
    else{
        if(jDateFecha.getDate() != null && niño.controlFecha(jDateFecha.getDate()) && jTxtDiagnostico.getText().equals("")){
            JOptionPane.showMessageDialog(null,"Ingrese diagnóstico/tratamiento", "Error", 2);
        }
        if(jDateFecha.getDate() != null && !niño.controlFecha(jDateFecha.getDate())){
            JOptionPane.showMessageDialog(null,"Ingrese fecha correcta", "Error", 2);
        }
        if(jDateFecha.getDate() == null && !jTxtDiagnostico.getText().equals("")){
            JOptionPane.showMessageDialog(null,"Ingrese fecha correcta", "Error", 2);
        }
    }
}//GEN-LAST:event_jBtnConfirmarActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.ButtonGroup buttonGroup3;
    private javax.swing.ButtonGroup buttonGroup4;
    private javax.swing.ButtonGroup buttonGroup5;
    private javax.swing.ButtonGroup buttonGroup6;
    private javax.swing.JButton jBtnConfirmar;
    private javax.swing.JButton jBtnSalir;
    private javax.swing.JCheckBox jCheck12ODCC;
    private javax.swing.JCheckBox jCheck12ODSC;
    private javax.swing.JCheckBox jCheck12OICC;
    private javax.swing.JCheckBox jCheck12OISC;
    private javax.swing.JCheckBox jCheck3ODCC;
    private javax.swing.JCheckBox jCheck3ODSC;
    private javax.swing.JCheckBox jCheck3OICC;
    private javax.swing.JCheckBox jCheck3OISC;
    private javax.swing.JCheckBox jCheck5ODCC;
    private javax.swing.JCheckBox jCheck5ODSC;
    private javax.swing.JCheckBox jCheck5OICC;
    private javax.swing.JCheckBox jCheck5OISC;
    private com.toedter.calendar.JDateChooser jDateFecha;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabelNombre;
    private javax.swing.JLabel jLabelPrematura1;
    private javax.swing.JLabel jLabelPrematura2;
    private javax.swing.JLabel jLabelPrematuro1;
    private javax.swing.JLabel jLabelPrematuro2;
    private javax.swing.JLabel jLabelTitular;
    private javax.swing.JLabel jLabelTitulo;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextField jText12;
    private javax.swing.JTextField jText12cc;
    private javax.swing.JTextField jText12sc;
    private javax.swing.JTextField jText3;
    private javax.swing.JTextField jText3cc;
    private javax.swing.JTextField jText3sc;
    private javax.swing.JTextField jText5;
    private javax.swing.JTextField jText5cc;
    private javax.swing.JTextField jText5sc;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextField jTextDiag;
    private javax.swing.JTextField jTextEdad;
    private javax.swing.JTextField jTextFecha;
    private javax.swing.JTextField jTextField13;
    private javax.swing.JTextField jTextField14;
    private javax.swing.JTextField jTextField15;
    private javax.swing.JTextField jTextField16;
    private javax.swing.JTextField jTextField17;
    private javax.swing.JTextField jTextField18;
    private javax.swing.JTextField jTextField19;
    private javax.swing.JTextField jTextField20;
    private javax.swing.JTextField jTextField21;
    private javax.swing.JTextField jTextField22;
    private javax.swing.JTextField jTextField23;
    private javax.swing.JTextField jTextField24;
    private javax.swing.JTextField jTextOd;
    private javax.swing.JTextField jTextOi;
    private javax.swing.JTextField jTxtDiagnostico;
    // End of variables declaration//GEN-END:variables
}
